# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=git-bug
pkgver=0.8.0
pkgrel=14
pkgdesc="Distributed, offline-first bug tracker embedded in git, with bridges"
url="https://github.com/MichaelMure/git-bug"
# loongarch64: blocked by bbolt
arch="all !loongarch64"
license="GPL-3.0-or-later"
makedepends="
	go
	npm
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="
	git-bug-$pkgver.tar.gz::https://github.com/MichaelMure/git-bug/archive/v$pkgver.tar.gz
	fix-tests.patch
	Makefile.patch
	"
options="net"

export GIT_COMMIT=v$pkgver
export GIT_LAST_TAG=v$pkgver
export GIT_EXACT_TAG=v$pkgver

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	default_prepare

	npm ci --prefix webui
}

build() {
	make pack-webui
	make
}

check() {
	make test
	cd webui
	make test
}

package() {
	install -Dm755 git-bug "$pkgdir"/usr/bin/git-bug

	install -Dm 644 misc/completion/bash/git-bug "$pkgdir"/usr/share/bash-completion/completions/git-bug
	install -Dm 644 misc/completion/fish/git-bug "$pkgdir"/usr/share/fish/vendor_completions.d/git-bug.fish
	install -Dm 644 misc/completion/zsh/git-bug "$pkgdir"/usr/share/zsh/site-functions/_git-bug

	install -Dm 644 doc/man/*.1 -t "$pkgdir"/usr/share/man/man1
}

sha512sums="
85456c916f72c0d2764ccd09418d2db91a9aeed48182de12d6aaec7cd021c55ec323822e4aa9347739cfe232ff2287e1bc7adca37ff2574d822b78fc75121d83  git-bug-0.8.0.tar.gz
54788f03849ea4022e942355024458008590f8b08c5d5e5a4b1255a461e4b3cce7242d97c948b6411613a3d6cd8b576ca58a49858a00206a91f6f83ca76f32fc  fix-tests.patch
fed7c606b146976cf2c3fc4c2849ae81e8f1dd17505863dcf5dcbafd4715a96d3a1984124e27c70b6a6aaf09f22a5b957fdfde7725132c8b775bdf5a6bce0a24  Makefile.patch
"
